package com.bdqn.ch01.conteller;

import com.bdqn.ch01.service.DemosService;
import com.bdqn.ch01.service.KtjiaoyuInfo;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    @Autowired
    private DemosService demosService;

    @RequestMapping("/hello")
    public String hello(){
        String msg = demosService.sayHello();
        return msg;
    }

    @Value("${src.ktjiaoyu.name}")
    public String name;
    @Value("${src.ktjiaoyu.email}")
    public String email;

    @RequestMapping("/hello1")
    public String hello1(){
        String msg = demosService.sayHello();
        msg += " " +name+ " "+ email;
        return msg;
    }

    @Resource
    private KtjiaoyuInfo ktjiaoyuInfo;
    @RequestMapping("/hello2")
    public String hello2(){
        String msg = demosService.sayHello();
        msg += " " +ktjiaoyuInfo.getName()+ " "+ ktjiaoyuInfo.getEmail();
        return msg;
    }
}
